package com.sojson.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.dao.UserRoleDao;
import com.sojson.entity.po.UserRole;
import com.sojson.service.UserRoleService;

/**
 * 用户和角色关联表Service实现类
 * 
 * @author liu
 * @date 2021-04-15
 */
@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Resource
    private UserRoleDao userRoleDaoImpl;

    /**
     * 单条插入
     * 
     * @param userRole
     * @return
     */
    @Override
    public int insert(UserRole userRole) {
        int insert = userRoleDaoImpl.insert(userRole);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param userRole
     * @return
     */
    @Override
    public int insertList(UserRole userRole) {
        int insertList = userRoleDaoImpl.insertList(userRole.getUserRoles());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int deleteByDto(UserRole userRole) {
        int deleteByDto = userRoleDaoImpl.deleteByDto(userRole);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     */
    @Override
    public int countAll() {
        int countAll = userRoleDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     */
    @Override
    public List<UserRole> findAll() {
        List<UserRole> findAll = userRoleDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param userRole
     * @return
     */
    @Override
    public int countByDto(UserRole userRole) {
        int countByDto = userRoleDaoImpl.countByDto(userRole);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param userRole
     * @return
     */
    @Override
    public List<UserRole> findByDto(UserRole userRole) {
        List<UserRole> findByDto = userRoleDaoImpl.listByDto(userRole);
        return findByDto;
    }

    /**
     * 通过roleId删除(物理删除)
     * 
     * @param roleId
     * @return
     */
    @Override
    public int deleteByRoleId(Integer roleId) {
        int deleteByRoleId = userRoleDaoImpl.deleteByRoleId(roleId);
        return deleteByRoleId;
    }

    /**
     * 通过roleId列表删除(物理删除)
     * 
     * @param roleIds
     * @return
     */
    @Override
    public int deleteByRoleIdList(List<Integer> roleIds) {
        int deleteByRoleIdList = userRoleDaoImpl.deleteByRoleIdList(roleIds);
        return deleteByRoleIdList;
    }

    /**
     * 通过roleId更新(全部更新)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateByRoleId(UserRole userRole) {
        int updateByRoleId = userRoleDaoImpl.updateByRoleId(userRole);
        return updateByRoleId;
    }

    /**
     * 通过roleId列表更新(全部更新)(更新内容相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateStaticByRoleIdList(UserRole userRole) {
        int updateStaticByRoleIdList = userRoleDaoImpl.updateStaticByRoleIdList(userRole);
        return updateStaticByRoleIdList;
    }

    /**
     * 通过roleId列表更新(全部更新)(更新内容不相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateChangeByRoleIdList(UserRole userRole) {
        int updateChangeByRoleIdList = userRoleDaoImpl.updateChangeByRoleIdList(userRole.getUserRoles());
        return updateChangeByRoleIdList;
    }

    /**
     * 通过roleId更新(局部更新)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updatePartialByRoleId(UserRole userRole) {
        int updatePartialByRoleId = userRoleDaoImpl.updatePartialByRoleId(userRole);
        return updatePartialByRoleId;
    }

    /**
     * 通过roleId列表更新(局部更新)(更新内容相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateStaticPartialByRoleIdList(UserRole userRole) {
        int updateStaticPartialByRoleIdList = userRoleDaoImpl.updateStaticPartialByRoleIdList(userRole);
        return updateStaticPartialByRoleIdList;
    }

    /**
     * 通过roleId列表更新(局部更新)(更新内容不相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateChangePartialByRoleIdList(UserRole userRole) {
        int updateChangePartialByRoleIdList = userRoleDaoImpl.updateChangePartialByRoleIdList(userRole.getUserRoles());
        return updateChangePartialByRoleIdList;
    }

    /**
     * 通过roleId查询
     * 
     * @param roleId
     * @return
     */
    @Override
    public UserRole findByRoleId(Integer roleId) {
        UserRole findByRoleId = userRoleDaoImpl.findByRoleId(roleId);
        return findByRoleId;
    }

    /**
     * 通过roleId列表查询
     * 
     * @param roleIds
     * @return
     */
    @Override
    public List<UserRole> findByRoleIdList(List<Integer> roleIds) {
        List<UserRole> findByRoleIdList = userRoleDaoImpl.findByRoleIdList(roleIds);
        return findByRoleIdList;
    }

    /**
     * 通过对象查询roleId列表
     * 
     * @param userRole
     * @return
     */
    @Override
    public List<Integer> findRoleIdByDto(UserRole userRole) {
        List<Integer> findRoleIdByDto = userRoleDaoImpl.findRoleIdByDto(userRole);
        return findRoleIdByDto;
    }

    /**
     * 通过userId删除(物理删除)
     * 
     * @param userId
     * @return
     */
    @Override
    public int deleteByUserId(Integer userId) {
        int deleteByUserId = userRoleDaoImpl.deleteByUserId(userId);
        return deleteByUserId;
    }

    /**
     * 通过userId列表删除(物理删除)
     * 
     * @param userIds
     * @return
     */
    @Override
    public int deleteByUserIdList(List<Integer> userIds) {
        int deleteByUserIdList = userRoleDaoImpl.deleteByUserIdList(userIds);
        return deleteByUserIdList;
    }

    /**
     * 通过userId更新(全部更新)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateByUserId(UserRole userRole) {
        int updateByUserId = userRoleDaoImpl.updateByUserId(userRole);
        return updateByUserId;
    }

    /**
     * 通过userId列表更新(全部更新)(更新内容相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateStaticByUserIdList(UserRole userRole) {
        int updateStaticByUserIdList = userRoleDaoImpl.updateStaticByUserIdList(userRole);
        return updateStaticByUserIdList;
    }

    /**
     * 通过userId列表更新(全部更新)(更新内容不相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateChangeByUserIdList(UserRole userRole) {
        int updateChangeByUserIdList = userRoleDaoImpl.updateChangeByUserIdList(userRole.getUserRoles());
        return updateChangeByUserIdList;
    }

    /**
     * 通过userId更新(局部更新)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updatePartialByUserId(UserRole userRole) {
        int updatePartialByUserId = userRoleDaoImpl.updatePartialByUserId(userRole);
        return updatePartialByUserId;
    }

    /**
     * 通过userId列表更新(局部更新)(更新内容相同)
     * 
     * @param userRole
     * @return
     */
    @Override
    public int updateStaticPartialByUserIdList(UserRole userRole) {
        int updateStaticPartialByUserIdList = userRoleDaoImpl.updateStaticPartialByUserIdList(userRole);
        return updateStaticPartialByUserIdList;
    }

    /**
     * 通过userId列表更新(局部更新)(更新内容不相同)
     * 
     * @param userRoles
     * @return
     */
    @Override
    public int updateChangePartialByUserIdList(UserRole userRole) {
        int updateChangePartialByUserIdList = userRoleDaoImpl.updateChangePartialByUserIdList(userRole.getUserRoles());
        return updateChangePartialByUserIdList;
    }

    /**
     * 通过userId查询
     * 
     * @param userId
     * @return
     */
    @Override
    public UserRole findByUserId(Integer userId) {
        UserRole findByUserId = userRoleDaoImpl.findByUserId(userId);
        return findByUserId;
    }

    /**
     * 通过userId列表查询
     * 
     * @param userIds
     * @return
     */
    @Override
    public List<UserRole> findByUserIdList(List<Integer> userIds) {
        List<UserRole> findByUserIdList = userRoleDaoImpl.findByUserIdList(userIds);
        return findByUserIdList;
    }

    /**
     * 通过对象查询userId列表
     * 
     * @param userRole
     * @return
     */
    @Override
    public List<Integer> findUserIdByDto(UserRole userRole) {
        List<Integer> findUserIdByDto = userRoleDaoImpl.findUserIdByDto(userRole);
        return findUserIdByDto;
    }

    /**
     * 清空数据(物理清空)
     */
    @Override
    public void clear() {
        userRoleDaoImpl.clear();
    }

}